package com.lhh.userservice.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lhh.springcommon.annotation.WebLog;
import com.lhh.springcommon.annotation.WithRequestId;
import com.lhh.springcommon.entity.Comment;
import com.lhh.springcommon.entity.vo.CommentVO;
import com.lhh.springcommon.utils.PageQuery;
import com.lhh.springcommon.utils.Response;
import com.lhh.userservice.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 评论
 * @author 李厚航
 * @date 2025-02-25
 */
@RestController
@RequestMapping("/comment")
public class CommentController {

    private final UserCommentService userCommentService;

    @Autowired
    public CommentController(UserCommentService userCommentService) {
        this.userCommentService = userCommentService;
    }

    /**
     * 删除评论
     * @param comment
     * @return
     */
    @DeleteMapping("/deleteComment")
    @WithRequestId
    @WebLog
    public Response<Boolean> deleteComment(@RequestBody Comment comment){
        return Response.success(userCommentService.delete(comment));
    }

    /**
     * 添加评论
     * @param comment
     * @return
     */
    @PostMapping("/addComment")
    @WithRequestId
    @WebLog
    public Response<CommentVO> addComment(@RequestBody Comment comment){
        return Response.success(userCommentService.add(comment));
    }

    /**
     * 分页查询视频评论
     * @return
     */
    @PostMapping("/queryPageComment")
    @WithRequestId
    @WebLog
    public Response<Page<CommentVO>> queryPageComment(@RequestBody PageQuery<PageQuery<Comment>> comment){
        return Response.success(userCommentService.queryPageComment(comment));
    }
}
